package com.sunshuo.springsecuritydemo.dao;

import com.sunshuo.springsecuritydemo.pojo.RoleMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @ClassName RoleMenuDao
 * @Description TODO
 * @Author sunshuo
 */
@Repository
public class RoleMenuDao {

    private JdbcTemplate jdbcTemplate;

    @Autowired
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public void deleteByRoleId(String roleId) {
        String sql = "delete from t_role_menu where role_id = ?";
        jdbcTemplate.update(sql, roleId);
    }

    public void add(RoleMenu roleMenu) {
        String sql = "insert into t_role_menu values(?, ?)";
        jdbcTemplate.update(sql, roleMenu.getRoleId(), roleMenu.getMenuId());
    }

}
